package com.cnd.scm.common.utils;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;

public class XStreamUtils {

	public static <T> T xmltoBean(String xmlStr, Class<T> cls) {
		XStream xstream = new XStream(new DomDriver("UTF-8"));
		xstream.ignoreUnknownElements();//设置忽略未知元素
		xstream.processAnnotations(cls);
		@SuppressWarnings("unchecked")
		T t = (T) xstream.fromXML(xmlStr);
		return t;
	}

}
